package com.baba.vote.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;

/**
 * @author moxinHuoHuo
 * @create 2020/6/28 下午5:43
 */
@Configuration
public class JwtTokenConfig {

  private final static String SIGNING_KEY = "uaa123";

  @Bean(name = "myJwtTokenStore")
  public TokenStore jwtTokenStore() {
    return new JwtTokenStore(jwtAccessTokenConverter());
  }

  @Bean
  public JwtAccessTokenConverter jwtAccessTokenConverter() {
    JwtAccessTokenConverter accessTokenConverter = new JwtAccessTokenConverter();
    accessTokenConverter.setSigningKey(SIGNING_KEY);
    accessTokenConverter.setVerifierKey(SIGNING_KEY);
    return accessTokenConverter;
  }

}
